package Objetos 
{
	import flash.display.MovieClip;
	/**
	 * ...
	 * @author ...
	 */
	public class Lama extends MovieClip
	{
		
		public function Lama()
		{
			this.x = Math.floor( Math.random() * ( 1 + ( Main.getStage().stage.stageWidth - this.width / 2 ) - ( Main.getInstance().MC_barradeenergia.x + Main.getInstance().MC_barradeenergia. width / 2 + this.width / 2 ) ) ) + Main.getInstance().MC_barradeenergia.x + Main.getInstance().MC_barradeenergia. width / 2 + this.width / 2;
			this.y = -this.height / 2;
		}
		
		public function update(): void
		{
			this.y += Main.getInstance().UI_velocidade;
			
			if (this.y >= Main.getStage().stage.stageHeight + this.width / 2)
			{
				this.x = Math.floor( Math.random() * ( 1 + ( Main.getStage().stage.stageWidth - this.width / 2 ) - ( Main.getInstance().MC_barradeenergia.x + Main.getInstance().MC_barradeenergia. width / 2 + this.width / 2 ) ) ) + Main.getInstance().MC_barradeenergia.x + Main.getInstance().MC_barradeenergia. width / 2 + this.width / 2;
			    this.y = -this.height / 2;
			}
			
			if (Main.getInstance().MC_heroi.hitTestObject(this))
			{
				Main.getInstance().BO_lama = true;
				
				Main.getInstance().SC_canallama                = Main.getInstance().SO_lama.play();
			    Main.getInstance().ST_transformarlama.volume   = 0.5;
			    Main.getInstance().SC_canallama.soundTransform = Main.getInstance().ST_transformarlama;
			}
			
			else
			{
				Main.getInstance().BO_lama = false;
				Main.getInstance().SC_canallama.stop();
			}
		}
	}
}